package com.ljtg.ljtgservice.mapper;

import com.github.pagehelper.Page;
import com.ljtg.enumeration.OperationType;
import com.ljtg.ljtgpojo.dto.CommodityDTO;
import com.ljtg.ljtgpojo.dto.CommodityPageDTO;
import com.ljtg.ljtgpojo.entity.Commodity;
import com.ljtg.ljtgservice.annotation.AutoFill;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CommodityMapper {

    /**
     * 根据分类id查询商品数量
     *
     * @param categoryId
     * @return
     */
    @Select("select count(id) from commodity where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);

    /**
     * 插入商品数据
     * @param commodity
     */
    @AutoFill(value = OperationType.INSERT)
    void insert(Commodity commodity);

    Commodity selectById(Long id);

    void updateById(Commodity commodity);

    void deleteById(Long id);

    Page<Commodity> PageQuery(CommodityPageDTO commodityPageDTO);

    List<Commodity> list(Commodity commodity);
}